#!/usr/bin/python
# -*- coding: UTF-8 -*-

from selenium.webdriver import ChromeOptions
import  time
from selenium.webdriver import Chrome
from UtilPackge import LoginUtil
from UtilPackge import Logger
from ProductType import  ProductTypeInfo
from ProductPublishInfoWrite.BasicInfoWrite import basicInfo
from ProductPublishInfoWrite.SaleInfo import MainSale
from ProductPublishInfoWrite.IMGDescribe import IMGMainFun

import win32api
import win32con
#关闭浏览器正在控制受自动化软件控制
option = ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])
driver = Chrome(options=option)

def SlidingMouse(index):
        win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0,index)



if __name__ == '__main__':

    filePath = r'C:\Users\Administrator\Desktop\colorTypeInfos.xlsx';

    filePath = r'C:\Users\hesy\Desktop\colorTypeInfos.xlsx'
    browser = driver

    #最大化浏览器
    browser.maximize_window()

    #请求地址
    browser.get('https://upload.taobao.com/auction/sell.jhtml?mytmenu=wym')

    LoginUtil.isLogin(browser);
    Logger.logger.info("~~~~~确认已经登录~~~~~")

    ProductTypeInfo.selectTypeAndPublish(browser)
    Logger.logger.info("~~~~~给商品选定类目~~~~~")

    basicInfo.basicInfowrate(browser,filePath)
    Logger.logger.info("~~~~~商品的基础信息设置完成~~~~~")

    #滑动鼠标
    time.sleep(2)
    js="var q=document.documentElement.scrollTop=900"
    browser.execute_script(js)

    MainSale.saleMainFun(browser,filePath);
    Logger.logger.info("~~~~~商品的颜色分类设置已完成~~~~~")

    #滑动鼠标
    time.sleep(2)
    js="var q=document.documentElement.scrollTop=1200"
    browser.execute_script(js)

    #上传主图
    IMGMainFun.IMGDescribeFun(browser,filePath)
    Logger.logger.info("~~~~~商品的主图设置已完成~~~~~")

  


